package com.winning.pmph.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.winning.pmph.entity.SpecialtyKnowledgeLib;
import com.winning.pmph.mapper.SpecialtyKnowledgeLibMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author admin
 */
@Service
@Transactional
public class SpecialtyKnowledgeLibService extends ServiceImpl<SpecialtyKnowledgeLibMapper, SpecialtyKnowledgeLib> {

    public Page<SpecialtyKnowledgeLib> selectList(SpecialtyKnowledgeLib specialtyKnowledgeLib) {
        return lambdaQuery().like(StringUtils.isNotBlank(specialtyKnowledgeLib.getName()),
                SpecialtyKnowledgeLib::getName, specialtyKnowledgeLib.getName())
                .eq(StringUtils.isNotBlank(specialtyKnowledgeLib.getCreatedBy()),
                        SpecialtyKnowledgeLib::getCreatedBy, specialtyKnowledgeLib.getCreatedBy())
                .like(StringUtils.isNotBlank(specialtyKnowledgeLib.getKnowledgeLibId()),
                        SpecialtyKnowledgeLib::getKnowledgeLibIdList, specialtyKnowledgeLib.getKnowledgeLibId())
                .orderByDesc(SpecialtyKnowledgeLib::getUpdatedTime)
                .orderByAsc(SpecialtyKnowledgeLib::getId)
                .page(new Page<>(specialtyKnowledgeLib.getCurrentPage(), specialtyKnowledgeLib.getPageSize()));
    }
}
